import { reactive } from 'vue'
import axios from 'axios'

export default function () {
    /* --------------------------- 数据 --------------------------- */
    let dogList = reactive([
        'https://images.dog.ceo/breeds/pembroke/n02113023_6030.jpg'
    ]);

    /* --------------------------- 方法 --------------------------- */
    async function getDog() {
        try {
            let res = await axios.get('https://dog.ceo/api/breed/pembroke/images/random');
            console.log(res.data.message);
            dogList.push(res.data.message);
        } catch (error) {
            alert(error);
        }
    }

    /* --------------------------- 暴露 --------------------------- */
    return {dogList, getDog}
}